package com.example.mapper;

import com.example.entity.Notice;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface NoticeMapper {


    @Select("select * from t_notices order by public_time desc")
    List<Notice> queryAllNotices();

    @Select("select * from t_notices order by public_time desc LIMIT 1")
    List<Notice> queryAllNoticeOnlyOne();

    @Insert("insert into t_notices (notice,public_time,remark) values(#{notice},#{public_time},#{remark})")
    void addNotice(@Param("notice") String notice, @Param("public_time") Date public_time, @Param("remark") String remark);

    @Insert("delete from t_notices where id=#{id}")
    void delNotice(@Param("id") int id);
}
